import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { ConnectVO } from '../vo/ConnectVO';
@Component({
  selector: 'app-servicecompanylist',
  templateUrl: './servicecompanylist.page.html',
  styleUrls: ['./servicecompanylist.page.scss'],
})
export class ServicecompanylistPage implements OnInit {
  
  constructor(public activatedRoute: ActivatedRoute,
    private router: Router) { }
    itype: string;
    tempitems: ConnectVO[] = [];
    items: ConnectVO[] = [];
  ngOnInit() {
    this.itype = this.activatedRoute.snapshot.paramMap.get('itype');
    this.tempitems = JSON.parse(this.activatedRoute.snapshot.paramMap.get('items'));
    this.shaixuan();
  }
  shaixuan() {
    console.log(this.tempitems.length);
    for (let i = 0; i < this.tempitems.length; i++) {
      if ( this.itype === '1') {
        if (this.tempitems[i].dconnecttime !== null) {
          this.items.push(this.tempitems[i]);
        }
      } else {
        if (this.tempitems[i].dconnecttime == null) {
          this.items.push(this.tempitems[i]);
        }
      }
}
  }
  goToDetails(iid) {
    this.router.navigate(['/companydetail', {'iid': iid}]);
  }
}
